package com.hollysys.hollimsa.biz.istio.destinationrule.domain;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.Valid;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.Pattern;
import java.io.Serializable;

/**
 * @author Administrator
 */
@ApiModel(value = "组件需要的参数",description = "组件需要的参数")
@Data
public class DestinationRuleVO implements Serializable {

    private static final long serialVersionUID = -4072106368586749714L;
    /* 组件名称 */
    @ApiModelProperty(value = "组件名称符合正则表达式 [a-z0-9]([-a-z0-9]*[a-z0-9])?",required = true)
    @NotEmpty(message = "组件名称不能为空")
    @Pattern(regexp = "[a-z0-9]([-a-z0-9]*[a-z0-9])?", message = "不符合 DNS1123_LABEL_REGEX")
    private String name;

    @ApiModelProperty(value = "关联底层服务|服务注册表中的服务名称",required = true)
    private String host;


    @ApiModelProperty(value = "版本划分-代表服务的各个版本的一个或多个命名集。可以在子集级别覆盖流量策略。")
    @Valid
    private InnerSubset[] subsets;


    @Data
    public static  class InnerSubset implements Serializable {

        private static final long serialVersionUID = 2115200473158221241L;
        @ApiModelProperty(value = "子集的名称。服务名称和子集名称可用于路由规则中的流量拆分。",required = true)
        @NotEmpty(message = "子集的名称是必须的")
        private String name;
        @ApiModelProperty(value = "标签在服务注册表中的服务端点上应用过滤器。")
        private String labels;

    }
}

